package servlet.DamServlets;

import dao.DamDAO;
import entity.Dam;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

@WebServlet("/UpdateDamViewServlet")
public class UpdateDamViewServlet extends HttpServlet

{
    Dam dam;
    DamDAO damDAO=new DamDAO();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id= Integer.parseInt(req.getParameter("id"));
        Dam dam=damDAO.findById(id);
        req.setAttribute("dam",dam);
        RequestDispatcher dispatcher = req.getRequestDispatcher("/UpdateDam.jsp");
        dispatcher.forward(req, resp);


    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        super.doPost(req, resp);
        doGet(req,resp);
    }
}
